package com.atguigu.tingshu.search.service;

import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import com.atguigu.tingshu.model.search.AlbumInfoIndex;
import com.atguigu.tingshu.model.search.SuggestIndex;
import com.atguigu.tingshu.query.search.AlbumIndexQuery;
import com.atguigu.tingshu.vo.search.AlbumInfoIndexVo;
import com.atguigu.tingshu.vo.search.AlbumSearchResponseVo;

import java.util.List;
import java.util.Map;

public interface SearchService {


    void upperAlbum(Long albumId);

    void saveSuggestIndex(AlbumInfoIndex albumInfoIndex);

    void lowerAlbum(Long albumId);

    /**
     * 站内条件检索专辑接口
     * @param albumIndexQuery
     * @return
     */
    AlbumSearchResponseVo albumSearch(AlbumIndexQuery albumIndexQuery);

    /**
     * 构建DSL
     * @param albumIndexQuery
     * @return
     */
    SearchRequest buildDSL(AlbumIndexQuery albumIndexQuery);

    /**
     * 解析DSL
     * @param searchResponse
     * @param albumIndexQuery
     * @return
     */
    AlbumSearchResponseVo parseSearchResult(SearchResponse<AlbumInfoIndex> searchResponse, AlbumIndexQuery albumIndexQuery);

    /**
     * 查询置顶3级分类下热度TOP6专辑列表
     * @param category1Id
     * @return
     */
    List<Map<String, Object>> searchTopCategoryHotAlbum(Long category1Id);

    /**
     * 根据用户已录入字符查询提词索引库进行自动补全关键字
     * @param keyword
     * @return
     */
    List<String> completeSuggest(String keyword);

    /**
     * 解析建议词结果
     * @param searchResponse
     * @param suggestName
     * @return
     */
    List<String> parseSuggestResult(SearchResponse<SuggestIndex> searchResponse, String suggestName);

    /**
     * 添加专辑播放量
     * @param albumId
     * @param statType
     */
    void addAlbumNum(Long albumId, String statType);

    /**
     * 更新不同分类不同排行TOP20数据
     *
     * @return
     */
    void updateLatelyAlbumRanking();

    /**
     * 查询排行榜
     * @param category1Id
     * @param dimension
     * @return
     */
    List<AlbumInfoIndexVo> findRankingList(Long category1Id, String dimension);
}
